<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html class="no-js">
<head>
<meta name="Keywords" content="<?php echo C('site_keyword');?>">
<meta name="Description" content="<?php echo C('site_content');?>">
<title><?php echo C('site_title');?></title>
<!-- 移动设备支持 -->
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="<?php echo STATICS;?>/amaze/css/amazeui.min.css?v=1.00">
<link rel="stylesheet" href="<?php echo RES;?>/css/app.css?v=2.27">
<script src="<?php echo STATICS;?>/amaze/js/jquery.min.js"></script>
<script src="<?php echo STATICS;?>/amaze/js/amazeui.min.js"></script>
<script src="<?php echo STATICS;?>/js/jquery.form.min.js"></script>
<script src="<?php echo RES;?>/js/common.js?v=1.00"></script>
</head>
<body>
<div id="loading" class="loading"><div class="loadMark"><i class="am-icon-spinner am-icon-pulse"></i></div></div>
<div class="page">
	

	
<header class="am-header am-header-default">
	<div class="am-header-left am-header-nav">
	<a href="<?php echo U('Index/index');?>"><i class="am-header-icon am-icon-home"></i></a>
    </div>
	<h1 class="am-header-title">商品详情</h1>
	<div class="am-header-right am-header-nav">
	<a href="javascript:window.history.go(-1)"><i class="am-header-icon am-icon-reply"></i></a>
	</div>
</header>

<div class="goodsInfo">
	<div data-am-widget="slider" class="am-slider am-slider-a1" >
		<ul class="am-slides">
			<?php if(is_array($album)): $i = 0; $__LIST__ = $album;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><img src="<?php echo ($vo["picname"]); ?>"></li><?php endforeach; endif; else: echo "" ;endif; ?>
		</ul>
	</div>

	<div class="goods-base">
		<div class="goods-name"><?php echo ($list['name']); if(!empty($list['intr'])): ?><p><?php echo ($list['intr']); ?></p><?php endif; if(($list["baoxian"]) == "1"): ?><div>送全年交强险<span style="font-size:1.2rem; color:#999; padding-left:5px">（五座车950元，七座车1100元 皆可）</span></div><?php endif; ?></div>		
	</div>

	<div class="goods-price"><span>￥<?php echo ($list['price']); ?></span><del><?php echo ($list['shichang']); ?></del><i><?php echo ($list['zhekou']); ?>折</i></div>


	<div class="goods-number">已销售：<?php echo ($list['sellNumber']); ?>件</div>

	<?php if(($list["hasoption"]) == "1"): ?><div class="goods-rule"><button class="am-btn am-btn-warning am-btn-sm" onclick="buyBtnEvent('buy')">选择<?php if(is_array($specs)): $i = 0; $__LIST__ = $specs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>&nbsp;<?php echo ($vo["title"]); endforeach; endif; else: echo "" ;endif; ?></button></div><?php endif; ?>

	<div class="goods-comment">
		<div class="hd"><p>评价</p><span><a href="<?php echo U('Comment/index',array('id'=>$list['id']));?>">共 <?php echo ($commentNum); ?> 条评价 <i class="am-icon-chevron-right"></i></a></span></div>
		<div class="bd">
			<?php if(is_array($comment)): $i = 0; $__LIST__ = $comment;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li>
				<p class="u"><?php echo ($vo["wxname"]); ?>&nbsp;
				<?php  for ($i=0; $i < $vo['star'] ; $i++) { echo '<i class="am-icon-star"></i>'; } ?><span><?php echo (date("Y-m-d",$vo["createTime"])); ?></span></p>
				<p><?php echo ($vo["content"]); ?></p>
				<p class="t">型号：<?php echo ($vo["pname"]); ?></p>
			</li><?php endforeach; endif; else: echo "" ;endif; ?>
		</div>
		<p><a href="<?php echo U('Comment/index',array('id'=>$list['id']));?>" class="am-btn am-btn-default am-btn-block">查看所有评论</a></p>
	</div>

	<div class="goods-content">
		  <div data-am-widget="tabs"class="am-tabs am-tabs-default my-tabs">
		      <ul class="am-tabs-nav am-cf">
		          <li class="am-active"><a href="[data-tab-panel-0]">商品介绍</a></li>
		          <li class=""><a href="[data-tab-panel-1]">参数规格</a></li>
		          <li class=""><a href="[data-tab-panel-2]">售后保障</a></li>
		      </ul>
		      <div class="am-tabs-bd">
		          <div data-tab-panel-0 class="am-tab-panel am-active"><?php echo ($list['content']); ?></div>
		          <div data-tab-panel-1 class="am-tab-panel"><?php echo ($list['parm']); ?></div>
		          <div data-tab-panel-2 class="am-tab-panel"><?php echo ($list['server']); ?></div>
		      </div>
		  </div>
	</div>

	<div class="goods-like">
		<div class="hd">猜你喜欢</div>
		<?php if(is_array($like)): $i = 0; $__LIST__ = $like;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li><a href="<?php echo U('Store/view',array('id'=>$vo['id']));?>"><img src="<?php echo ($vo["picname"]); ?>" alt=""><p><?php echo ($vo["name"]); ?></p><span>￥<?php echo ($vo["price"]); ?></span></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
	</div>
</div>


<div class="view-btn">
<?php  if ($_user['status']) { ?>
	<a href="javascript:void(0)" onclick="addFav(<?php echo ($list['id']); ?>,'<?php echo ($list['name']); ?>','<?php echo ($list['price']); ?>','<?php echo ($list['picname']); ?>')"><i class="am-icon-star-o"></i>收藏</a>	
	<a href="<?php echo U('Store/cart');?>"><i class="am-icon-shopping-cart"></i>购物车(<span id="cartNum"><?php echo ($cartNum); ?></span>)</a>
<?php if(($list["hasoption"]) == "1"): ?><a href="javascript:void(0)" onclick="buyBtnEvent('add')" class="favBtn">加入购物车</a>
	<a href="javascript:void(0)" onclick="buyBtnEvent('buy')" class="buyBtn">立即购买</a>
<?php else: ?>
	<a href="javascript:void(0)" onclick="addCart(<?php echo ($list['id']); ?>)" class="favBtn">加入购物车</a>
	<a href="<?php echo U('Store/Buy',array('goodsID'=>$list['id']));?>" class="buyBtn">立即购买</a><?php endif; ?>
<?php  }else{ ?>
<div class="am-u-sm-6">
	<button type="button" class="am-btn am-btn-success am-btn-block" onclick="login()"><i class="am-icon-plus"></i> 加入购物车</button>
</div>
<div class="am-u-sm-6">
	<button type="button" class="am-btn am-btn-danger am-btn-block" onclick="login()"><i class="am-icon-cart-plus"></i> 立即购买</button>
</div>
<?php  } ?>
</div>


<div class="am-modal am-modal-no-btn" tabindex="-1" id="cartModel">
    <div class="am-modal-dialog" id="btn-response">
      <div class="am-modal-hd">选择商品规格
        <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
      </div>
      <div class="am-modal-bd">
      	<p>价格：<span id="productprice"><?php echo ($list['price']); ?></span></p>
        <div class="goods-pram">
        	<?php if(is_array($specs)): $i = 0; $__LIST__ = $specs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><input type='hidden' class='optionid optionid_<?php echo ($vo["id"]); ?>' value="" title="<?php echo ($vo["title"]); ?>">
        	<dl <?php if($i==1){echo 'class="fist"';}?>>
            	<dt class="spec_name"><?php echo ($vo["title"]); ?>:</dt>
                <dd class="spec_items options_<?php echo ($vo["id"]); ?>" specid="<?php echo ($vo["id"]); ?>">
                	<?php if(is_array($vo["items"])): $i = 0; $__LIST__ = $vo["items"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo2): $mod = ($i % 2 );++$i;?><a class="option option_<?php echo ($vo["id"]); ?>" href="javascript:;" specid="<?php echo ($vo["id"]); ?>" oid="<?php echo ($vo2["id"]); ?>" sel='false'><?php echo ($vo2["title"]); ?></a><?php endforeach; endif; else: echo "" ;endif; ?>
                    <div class="clear"></div>
                </dd>
                <dd class="clear"></dd>
            </dl><?php endforeach; endif; else: echo "" ;endif; ?>
        </div>
        <div class="modal-msg"></div>
        <input type="button" id="modal-btn" value="加入购物车" class="am-btn am-btn-block am-btn-danger">
      </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
	$("#modal-btn").click(function(){
		action = $("#action").val();
		goodsID = $("#goodsID").val();
		optionid = $("#optionid").val();

		if(optionid==""){
			alert("请选择规格");
			return false;	
		}

		//操作部分
		if (action=="add"){
			//加入到购物车
			$('#modal-btn').val('操作中...').attr('disabled',"true");
			$.get("index.php?m=Store&a=addcart&goodsID="+goodsID+"&optionid="+optionid+"&temp="+new Date().getTime(),function(response){
				$('#cartModel').modal('close');
				$('#modal-btn').val('加入购物车').removeAttr('disabled',"false");
				_alert(response);
				v = parseInt($('#cartNum span').html())+1;
       			$('#cartNum span').html(v);
			});
		}else if(action=="buy"){
			//跳转到购买
			window.location.href="index.php?m=Store&a=buy&goodsID="+goodsID+"&optionid="+optionid;
		}
	})
})


var _options =<?php  echo json_encode($options); ?>;
var specs =<?php  echo json_encode($specs); ?>;
var hasoption = <?php echo $list['hasoption']=='1'?'true':'false'; ?>;
$(".option").click(function () {
	var specid = $(this).attr("specid");
    var oid = $(this).attr("oid");
    $(".optionid_" + specid).val(oid);
	$(".options_" + specid + " a").removeClass("current").attr("sel", "false");
    $(this).addClass("current").attr("sel", "true");
	var optionid = "";
    var stock = 0;
    var marketprice = 0;
    var productprice = 0;
	var ret = option_selected();
	if (ret.no == '') {
		var len = _options.length;
		for (var i = 0; i < len; i++) {
           var o = _options[i];
		   ret.all = ret.all.sort(function(a,b){
			  return a-b;
		   });
           var ids = ret.all.join("_");
		   var specs=o.specs.split("_");
		   specs = specs.sort(function(a,b){
			  return a-b;
		   });
		   specs = specs.join("_");
           if (specs == ids) {
               optionid = o.id;
               stock = o.stock;
               productprice = o.productprice;
               break;
          }
       }
	   $("#optionid").val(optionid);
       $("#productprice").html(productprice);	
	}
})
function option_selected(){
   var ret= {
       no: "",
       all: []
   };
   if(!hasoption){
       return ret;
   }
   $(".optionid").each(function(){
       ret.all.push($(this).val());
       if($(this).val()==''){
		   ret.no = $(this).attr("title");
           return false;
       }
   });
   return ret;
}
<!--规格选择JS End-->
</script>
<input type="hidden" id="optionid" name="optionid" value=""/>
<input type="hidden" id="goodsID" name="goodsID" value="<?php echo ($list['id']); ?>" />  
<input type="hidden" id="action" name="action" value="" />
	<div class="kefu"><a href="http://chat32.live800.com/live800/chatClient/chatbox.jsp?companyID=672718&configID=95684&jid=7284455908"><i class="am-icon-headphones"></i></a></div>
	<footer data-am-widget="footer" class="am-footer am-footer-default"  data-am-footer="{}">
	    <div class="am-footer-miscs ">
	        <p>版权所有：<?php echo C("copyright");?></p>
	    </div>
	</footer>

	<script>
	var mid = document.getElementById("loading");
	wh = $(document).height();
	ww = $(document).width();
	$(mid).height(wh);
	$(".loadMark").css("left",(ww/2)-40);
	$("body").css({overflow:"hidden"});//禁用滚动条
	$(window).load(function() {
	   $(mid).hide();
	   $("body").css({overflow:"auto"});//禁用滚动条
	});
	</script>

</div>
</body>
</html>